package com.kabigon.config;

import com.kabigon.message.Demo01Message;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;

/**
 * @author xu.biao
 * @version v1.0
 * @Package com.kabigon.config
 * @data 2023/3/5 16:17
 */
public class DirectExchangeDemoConfiguration {

    @Bean
    public Queue demo01Queue() {
        return new Queue(
                Demo01Message.QUEUE, // Queue 名字
                true, // durable 是否持久化
                false, // exclusive 是否排他
                false // autoDelete 是否自动删除
        );
    }

    @Bean
    public DirectExchange demo01Exchange() {
        return new DirectExchange(Demo01Message.EXCHANGE, true, false);
    }

    @Bean
    public Binding demo01Binding() {
        return BindingBuilder.bind(demo01Queue()).to(demo01Exchange()).with(Demo01Message.ROUTING_KEY);
    }

}
